#include <bits/stdc++.h>
using namespace std;

void forward(int &x, int &y, int dir) {
  switch (dir) {
  case 0:
    x++;
    break;
  case 1:
    y++;
    break;
  case 2:
    x--;
    break;
  case 3:
    y--;
    break;
  }
}

void backward(int &x, int &y, int dir) {
  switch (dir) {
  case 0:
    x--;
    break;
  case 1:
    y--;
    break;
  case 2:
    x++;
    break;
  case 3:
    y++;
    break;
  }
}

int main() {
  string s;
  cin >> s;
  int x = 0, y = 0;
  int dir = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'L') {
      dir = (dir + 1) % 4;
    } else if (s[i] == 'R') {
      dir = (dir + 3) % 4;
    } else if (s[i] == 'F') {
      forward(x, y, dir);
    } else if (s[i] == 'B') {
      backward(x, y, dir);
    }
  }
  cout << x << " " << y << endl;
  return 0;
}